package com.jeff.android.lab.architecture.jframework;

import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import com.jeff.android.lab.BaseFragment;
import com.jeff.android.lab.R;
import com.jeff.android.lab.jframework.RuntimeManager;
import com.jeff.android.lab.jframework.app.NetworkChangeListener;

import butterknife.BindView;

/**
 * @author: duff
 * @date: 2019/1/15
 * @since: 1.0.0
 */
public class JFrameworkFragment extends BaseFragment
        implements NetworkChangeListener {

    @BindView(R.id.tv_network_state)
    TextView mTvNetworkState;

    @Override
    protected int getRootLayout() {
        return R.layout.architecture_fragment_jframework;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        RuntimeManager.instance().registerNetworkChangeListener(this);
    }

    @Override
    public void onConnect() {
        mTvNetworkState.setText("网络状态：连接");
        Toast.makeText(getContext(), "Network connect ... ", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onDisconnect() {
        mTvNetworkState.setText("网络状态：断开");
        Toast.makeText(getContext(), "Network disconnect ... ", Toast.LENGTH_SHORT).show();
    }

}
